package com.cw.reduce.filter;

import java.util.Vector;

public class DigitFilter implements IFilter {
	private int type;

	public DigitFilter(int type) {
		this.type = type;
	}

	/**
	 * getFilter
	 * 
	 * @param condition
	 *            Object
	 * @param target
	 *            Vector
	 * @return Vector
	 * @todo Implement this cp.gui.reduce.filter.IFilter method
	 */
	public Vector startFilter(Vector condition, Vector<Integer> target) {
		Vector result = new Vector();
		switch (type) {
		case 0:
			for (int i = 0; i < target.size(); i++) {
				int value = target.get(i);
				if (condition.contains(value / 100)) {
					result.add(value);
				}
			}
			break;
		case 1:
			for (int i = 0; i < target.size(); i++) {
				int value = target.get(i);
				if (condition.contains((value / 10) % 10)) {
					result.add(value);
				}
			}
			break;
		case 2:
			for (int i = 0; i < target.size(); i++) {
				int value = target.get(i);
				if (condition.contains(value % 10)) {
					result.add(value);
				}
			}
			break;
		}
		return result;
	}
}
